package com.ai.main.controller;

import com.ai.main.tool.DateTimeTools;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能描述
 *
 * @author: jichao.huang
 * @date: 2025年06月09日 10:59
 */
@RequiredArgsConstructor
@RequestMapping("/api/tool")
@RestController
public class ToolController {
    final ChatModel  chatModel;
    //final ChatClient chatClient;

    @GetMapping("/chat")
    public String chat(@RequestParam("input") String input) {
        //String result = chatClient.prompt(input)
        String result = ChatClient.create(chatModel).prompt()
                .user(input)
                .tools(new DateTimeTools())
                .call()
                .content();
        System.out.println("大模型调用工具返回结果:"+result);
        return result;
    }
}
